package com.young.test.aop;

import org.apache.log4j.Logger;

import javax.inject.Named;

import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;

@Named
@Aspect
public class AfterReturnAdvice {
	/**
	 * Logger for this class
	 */
	private static final Logger logger = Logger.getLogger(AfterReturnAdvice.class);

	/*
	 @AfterReturning(
			pointcut="com.young.test.aop.SystemArchitecture.forAspectBeanOperation() && com.young.test.aop.SystemArchitecture.forAllPublicMethod()",
			returning="retVal")
	public void objectReturnAdvice(Object retVal){
		logger.info("----Object-----");
		logger.info(retVal.toString());
		logger.info("----Object end-----");
	}
	*/
	@AfterReturning(
			pointcut="com.young.test.aop.SystemArchitecture.forAspectBeanOperation() && !com.young.test.aop.SystemArchitecture.forAllPublicVoidMethod()",
			returning="retVal")
	public void stringReturnAdvice(String retVal){
		logger.info("----String-----");
		logger.info(retVal);
		logger.info("----String end-----");
	}
	
	@AfterReturning(
			pointcut="com.young.test.aop.SystemArchitecture.forAspectBeanOperation() && !com.young.test.aop.SystemArchitecture.forAllPublicVoidMethod()",
			returning="retVal")
	public void integerReturnAdvice(Integer retVal){
		logger.info("----Integer-----");
		logger.info(retVal.toString());
		logger.info("----Integer end-----");
	}
}
